package com.sa.token.message;

/**
 * @desc: 全局状态码和msg
 * @author: xhs
 * @date: 2021/8/20 13:51
 * @version: JDK 1.8
 */
public enum Result {

    /**
     * 成功的状态码 200开头
     */
    SUCCESS(200, "操作成功"),
    ADD_SUCCESS(200, "新增成功"),
    DEl_SUCCESS(200, "删除成功"),
    UPD_SUCCESS(200, "更新成功"),
    QUERY_SUCCESS(200, "查询成功"),
    REGISTER_SUCCESS(200, "注册成功"),
    NO_DATA(200, "暂无数据"),
    FROZEN_ACCOUNT(200, "账号已冻结"),
    THAW_ACCOUNT(200, "账号已解冻"),
    ASSIGN_PERMISSIONS_SUCCESS(200, "分配权限成功"),
    SET_ROLE_SUCCESS(200, "设置角色成功"),

    /**
     * 失败的状态码 9开头 4位
     */
    ERROR(9999, "系统异常"),
    ADD_ERROR(9998, "新增失败"),
    DEl_ERROR(9997, "删除失败"),
    UPD_ERROR(9996, "更新失败"),
    QUERY_ERROR(9995, "查询失败"),
    ROLE_EXIST_ERROR(9994,"角色已存在"),
    MENU_EXIST_ERROR(9993,"菜单已存在"),
    MENU_PATH_EXIST_ERROR(9992, "路由地址已存在"),
    ACCOUNT_PASSWORD_ERROR(9001, "账号密码错误"),
    ACCOUNT_ALREADY_ERROR(9002, "账号已存在"),
    UPD_PWD_TWO_ERROR(9003, "二次输入的密码不一致"),
    UPD_PWD_OLDANDNEW_ERROR(9004, "新密码和旧密码不能相同"),
    UPD_PWD_ERROR(9005, "旧密码错误"),
    USER_NOT_EXIST_ERROR(9006, "用户不存在"),
    ROLE_NOT_EXIST_ERROR(9007, "角色不存在"),
    ASSIGN_PERMISSIONS_ERROR(9008, "分配权限失败"),
    SET_ROLE_ERROR(9009, "设置角色失败"),

    ;

    /**
     * 状态码
     */
    private final Integer code;

    /**
     * msg消息
     */
    private String msg;


    Result(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }


    public Integer getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }

    public Result formatMsg(String str) {
        this.msg = str;
        return this;
    }
}
